program SearchEngine;
var
  Form: TForm;
  Label1,Label2,Label3: TLabel;
  Button: TButton;
  OKB,CB:TButton;
  Edit1,Edit2,Edit3: TEdit;
  Memo: TMemo;
  i:integer;
  
const
 txt1 = '<script type="text/javascript">'#10+
'//SearchEngine Script. Copyright 2005 by Michal Gajek'#10+
'//migajek@yahoo.com , http://migajek.com'#10+
'keywords = new Array();'#10+
'url = new Array();'#10+
'title= new Array();'#10#10;
txt2 ='function Search(txt){'#10#10+
'var'#10+
' results = new String();'#10#10+
'for (i=0;i<keywords.length;i++){'#10+
' var str= new String(keywords[i]);'#10+
' if (str.indexOf(txt)>-1) {'#10+
'  results += ''<a href="''+url[i]+''">''+title[i]+''</a><br>'';'#10+
' }'#10+
'}'#10#10+

'document.getElementById("sres").innerHTML = results;'#10+
'}'#10#10+
'</script>'#10+
'<div id="sres"> </div>'#10+
'<form>'#10+
'<input name="stxt" value="">'#10+
'<input type="button" onclick="Search(this.form.stxt.value);"></form>';
procedure buttonclick(sender: TObject);
var
idx:string;
begin
idx:=inttostr(i);
if (Edit1.Text<>'')and(Edit2.Text<>'')and(Edit3.Text<>'') then
 begin
  memo.lines.Add('keywords['+idx+'] = '''+Edit1.Text+''';');
  memo.lines.Add('url['+idx+'] = '''+Edit2.Text+''';');
  memo.lines.Add('title['+idx+'] = '''+Edit3.Text+''';');
  I:=i+1;
  edit1.text:='';
  edit2.text:='';
  edit3.text:='';
 end;
end;

procedure close;
begin
Form.Visible:=false;
end;

procedure OKClick(Sender:TObject);
begin
AddText(txt1+Memo.Lines.Text+txt2);
close;
end;

procedure CBClick(sender:TObject);
begin
close;
end;

Begin
  Form := TForm.Create(self);
  Form.Width := 400;
  Form.Height := 340;
  Form.BorderStyle := bsToolWindow;
  Form.Caption := 'Search Engine Creator';
  Form.Position := poScreenCenter;
  
  Edit1 := TEdit.Create(Form);
  Edit1.Font.Name := 'Tahoma';
  Edit1.SetBounds(105,170,250,24);
  Edit1.Parent := Form;
  
  Label1:= TLabel.Create(Form);
  Label1.Caption := 'Keywords: ';
  Label1.SetBounds(10,172,100,24);
  Label1.Parent:= Form;
  
  Edit2 := TEdit.Create(Form);
  Edit2.Font.Name := 'Tahoma';
  Edit2.SetBounds(105,200,250,24);
  Edit2.Parent := Form;

  Label2:= TLabel.Create(Form);
  Label2.Caption := 'Url: ';
  Label2.SetBounds(10,202,100,24);
  Label2.Parent:= Form;

  Edit3 := TEdit.Create(Form);
  Edit3.Font.Name := 'Tahoma';
  Edit3.SetBounds(105,230,250,24);
  Edit3.Parent := Form;

  Label3:= TLabel.Create(Form);
  Label3.Caption := 'Title: ';
  Label3.SetBounds(10,232,100,24);
  Label3.Parent:= Form;
  
  Button := TButton.Create(Form);
  Button.Left := 311;
  Button.Top := 255;
  Button.Width := 45;
  Button.Height := 24;
  Button.Caption := 'Add';
  Button.OnClick := @buttonclick;
  Button.Parent := Form;
  Button.Default := True;
  
  OKB := TButton.Create(Form);
  OKB.Caption := 'OK';
  OKB.SetBounds(290,280,65,25);
  OKB.OnClick:=@OKClick;
  OKB.Parent:=form;

  CB := TButton.Create(Form);
  CB.Caption := 'Cancel';
  CB.SetBounds(200,280,65,25);
  CB.OnClick:=@CbClick;
  CB.Parent:=form;
  
  Memo := TMemo.Create(Form);
  Memo.Left := 10;
  Memo.Width := 380; 
  Memo.Top := 10;
  Memo.Height := 150;
  Memo.Text := '';
  Memo.Parent := Form;
  
  Form.FormStyle:=fsStayOnTop;
  Form.Visible := true;

  while Form.Visible  do
  begin
    Application.HandleMessage;
  end;
  Button.Free;
  Form.Free;
End.
